package com.ugtss.busniess.controller;


import com.ugtss.busniess.domain.Student;
import com.ugtss.busniess.domain.StudentEmployment;
import com.ugtss.busniess.service.StudentEmploymentService;
import com.ugtss.busniess.service.StudentService;
import com.ugtss.common.annotation.Anonymous;
import com.ugtss.common.core.controller.BaseController;
import com.ugtss.common.core.domain.AjaxResult;
import com.ugtss.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/studentEmployment")
public class StudentEmploymentController extends BaseController {

    @Autowired
    private StudentEmploymentService studentEmploymentService;

    /**
     * 分页查询学生就业信息
     *
     * @param  studentEmployment 查询条件
     * @return 分页后的学生信息列表
     */
    @GetMapping("getPage")
    public TableDataInfo list(StudentEmployment studentEmployment)
    {
        startPage();
        List<StudentEmployment> list = studentEmploymentService.selectStudentEmploymentList(studentEmployment);
        return getDataTable(list);
    }

    /**
     * 获取单个学生就业详情
     *
     * @param id 学生ID
     * @return 学生详情
     */
    @GetMapping("/{id}")
    public AjaxResult getStudentEmploymentById(@PathVariable Integer id) {
        StudentEmployment studentEmployment = studentEmploymentService.getStudentEmploymentById(id);
        if (studentEmployment == null) {
            return AjaxResult.error();
        }
        return AjaxResult.success(studentEmployment);
    }

    /**
     * 保存或更新就业信息
     *
     * @param studentEmployment 学生就业情况对象
     * @return 保存或更新后的就业信息
     */
    @PostMapping
    public AjaxResult saveOrUpdateStudentEmployment(@RequestBody StudentEmployment studentEmployment) {
        return AjaxResult.success(studentEmploymentService.saveOrUpdateStudentEmployment(studentEmployment));
    }

    /**
     * 删除就业
     *
     * @param id 就业情况ID
     * @return 成功响应
     */
    @DeleteMapping("/{id}")
    public AjaxResult deleteStudent(@PathVariable Integer id) {
        return AjaxResult.success(studentEmploymentService.deleteById(id));
    }
}